package com.ym.script.command;

import java.lang.reflect.Method;

import dalvik.system.PathClassLoader;

public class Am {
	//com.android.commands.am.Am
	static PathClassLoader loader = new PathClassLoader(
			"/system/framework/am.jar",
			ClassLoader.getSystemClassLoader());
	static Class<?> clzz;
	static Method runFuction;
	static Object instance;
	static {
		try {
			clzz = loader.loadClass("com.android.commands.am.Am");
			instance = clzz.newInstance();
			runFuction = clzz.getMethod("run", new String[0].getClass());
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void run(String args){
		run(args.split(" "));
	}
	public static void run(String[] args){

		try {
			runFuction.invoke(instance, new Object[]{args});
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
}
